<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>phonegap_device_network_notification01</title>
<link href="../jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css"/>
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="../cordova.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">

    // 等待Cordova加载
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova加载完成
    function onDeviceReady() {
    	$('#getCurrentHeading').click(function(){
    		navigator.compass.getCurrentHeading(onSuccess, onError);   
    	})    			 
    }
    function onSuccess(heading){
    	alert('Heading: ' + heading.magneticHeading);    	
    }
    function onError(compassError) {
        alert('Compass Error: ' + compassError.code);
    }  
 </script>

</head> 
<body>
<div data-role="page">
		<div data-role="header">
			<h1>PhoneGap100实战</h1>
		</div>
		<div data-role="content">
			 <h1>指南针例子</h1>
			 <a href="#" data-role='button' id="getCurrentHeading">点击获取当前的朝向</a>
   			 <p>getCurrentHeading</p> 
		</div>		
		<div data-role="footer">
			<h4>&nbsp;</h4>
		</div>
</div>

</body>
</html>
